import CodeView from '../../../shared/components/CodeView';
import CodeBlock from '../../../shared/components/CodeBlock';
import Blockquote from '../../../shared/components/Blockquote';
import { getDisplayElementById } from '../../shared/helpers';
import * as PathExamples from './base/example';
import { MobileNotice, MobileBlurb } from '../../shared/doc-text';

<div className="lead doc">
  The Path communicates to the user the progress of a particular process.
</div>

<CodeView exampleOnly>
  {getDisplayElementById(PathExamples.states, 'later-stage')}
</CodeView>

## About Path

### Accessibility

This component importantly changes role depending on what state it is in. If a Path comes with Stage Coaching information, this pattern lends itself perfectly to being a traditional Tab Set. As you navigate the Path Stages, it's associated content changes with it.

On the other hand, if a Path doesn't have Path Stage Coaching information, we can no longer use the Tab Set role, as we would effectively be misleading our users because each Tab has no associated content. This may lead to users trying to find absent content. In this situation, this component is much more suited to being a Listbox component.

The markup structure is identical, just some attributes change their values.

|  DOM Node        | Without Coaching  | With Coaching  |
|------------------|-------------------|----------------|
| .slds-path__nav  | role="listbox"    | role="tabset"  |
| .slds-path__link | role="option"     | role="tab"     |

#### Without Coaching

- `aria-orientation="horizontal"` should be applied to the `slds-path__nav` element to indicate to the screen reader to use horizontal navigation
- `aria-selected="true"` should be applied to the selected Stage of the Path as you navigate through the Stages

#### With Coaching

- When the Path Stage Coaching is not visible, `aria-expanded="false"` should be set on each `slds-path__link` Tab
- When the Path Stage Coaching is visible, `aria-expanded` should be set to `true`
- `aria-selected="true"` is used to describe the currently active `slds-path__link` Tab, not the Stage the Path is currently set to

### Keyboard Navigation

- For both with and without Path Stage Coaching variants, the following keyboard navigation applies
- `left` and `right` arrow keys move focus _and_ selection, with `aria-selected="true"`

### Mobile

<MobileBlurb patternSpecificText="elements of path will have an increased size to accommodate tapping with a finger instead of the more precise mouse cursor" />

<CodeView frameOnly frameTitle="Example mobile styles for path">
  {getDisplayElementById(PathExamples.states, 'later-stage')}
</CodeView>

## Examples

### Base

<CodeView>
  {getDisplayElementById(PathExamples.default)}
</CodeView>

### In a later stage

<CodeView>
  {getDisplayElementById(PathExamples.states, 'later-stage')}
</CodeView>

### With different stage selected

<CodeView>
  {getDisplayElementById(PathExamples.states, 'different-stage-selected')}
</CodeView>

### With visible tooltip

<CodeView demoStyles="min-height: 5rem;">
  {getDisplayElementById(PathExamples.states, 'with-visible-tooltip')}
</CodeView>

### With coaching available

<CodeView>
  {getDisplayElementById(PathExamples.states, 'with-coaching')}
</CodeView>

### With different stage selected - with coaching

<CodeView>
  {getDisplayElementById(PathExamples.states, 'different-coaching')}
</CodeView>

### Lost

<CodeView>
  {getDisplayElementById(PathExamples.states, 'lost')}
</CodeView>

### Won

<CodeView>
  {getDisplayElementById(PathExamples.states, 'won')}
</CodeView>

### Path with overflow

<CodeView>
  {getDisplayElementById(PathExamples.states, 'with-overflow')}
</CodeView>

### Layout overrides

When the Path needs to be placed in a more narrow column on desktop (between 360px and 564px) the class `.slds-region_small` should be placed on the container so it can adapt. If the container is between 565px and 1280px, the class `.slds-region_medium` should be applied.

#### Medium layout

With the class `.slds-region_medium` applied to the container.

<CodeView>
  {getDisplayElementById(PathExamples.states, 'medium')}
</CodeView>

#### Medium layout with coaching

With the class `.slds-region_medium` applied to the container.

<CodeView>
  {getDisplayElementById(PathExamples.states, 'medium-coaching')}
</CodeView>

#### Small layout

With the class `.slds-region_small` applied to the container.

<CodeView>
  {getDisplayElementById(PathExamples.states, 'small-coaching')}
</CodeView>
